package com.linwen.excise.leetcode;

/**
 * @ClassName _1523在区间范围内统计奇数数目
 * @Description TODO
 * @Author zero
 * @DATE 2024/10/7 2:23 PM
 * @Version 1.0
 */
public class _1523在区间范围内统计奇数数目 {
    public static void main(String[] args) {
        _1523在区间范围内统计奇数数目 inst = new _1523在区间范围内统计奇数数目();
        int low = 3;
        int high = 7;
        System.out.println(inst.countOdds(low,high));
        System.out.println(inst.countOdds2(low,high));
    }

    public int countOdds(int low, int high) {
        if((low&1)==1||((high&1)==1)){
            return (high-low)/2+1;
        }else {
            return (high-low)/2;
        }
    }

    public int countOdds2(int low, int high) {
        return ((high + 1) >> 1) - (low >> 1);
    }
}
